<script setup lang="ts">
import { PAGINATIONFOOT } from "@/utils/staticData";
import { useSystemStoreWithOut } from "@/store/modules/system";
import { storeToRefs } from "pinia";

const systemStore = useSystemStoreWithOut();
const { materialTypeList } = storeToRefs(systemStore);

defineOptions({ name: "manageTable" });

defineProps({
  tableHeight: { default: 0, type: Number },
  tableData: { type: Array, default: () => [] },
  pagination: { type: Object, default: () => {} }
});
</script>

<template>
  <el-table
    :data="tableData"
    class="tableBox"
    style="width: 100%"
    :height="
      tableHeight - (pagination.total > pagination.size ? PAGINATIONFOOT : 0)
    "
  >
    <el-table-column type="index" label="序号" min-width="88px" />
    <el-table-column
      prop="warehouseCode"
      label="仓库编号"
      min-width="104px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="warehouseName"
      label="仓库名称"
      min-width="152px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="materialCode"
      label="物料编码"
      min-width="104px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="materialName"
      label="物料名称"
      min-width="120px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="materialType"
      label="物料类型"
      min-width="104px"
      show-overflow-tooltip
    >
      <template #default="{ row }">
        {{
          materialTypeList.find(
            item => item.dictLabelValue === row.materialType
          )?.dictLabelName
        }}
      </template>
    </el-table-column>
    <el-table-column
      prop="materialSpecs"
      label="物料规格"
      min-width="200px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="unit"
      label="单位"
      min-width="80px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="instockNum"
      label="可用库存"
      min-width="104px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="transitNum"
      label="在途库存"
      min-width="104px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="lockNum"
      label="冻结库存"
      min-width="104px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="defectNum"
      label="不合格品库存"
      min-width="136px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="updateTime"
      label="库存变动时间"
      min-width="200px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="stocktakingTime"
      label="盘点完成时间"
      min-width="200px"
      show-overflow-tooltip
    />
  </el-table>
</template>
